package dimension.starry.item;

import dimension.starry.StarryDimension;
import dimension.starry.item.armor.FirstArmor;
import dimension.starry.item.food.Shit;
import dimension.starry.item.material.*;
import dimension.starry.item.ore.*;
import dimension.starry.item.tool.BreakingHammer;
import dimension.starry.item.tool.Kettle;
import dimension.starry.item.tool.LeatherKettle;
import dimension.starry.item.weapon.FirstSword;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

import java.util.Arrays;

public enum ItemRegisterManager {

    SHIT("shit", new Shit()),
    KETTLE("kettle", new Kettle()),
    LEATHER_KETTLE("leather_kettle", new LeatherKettle()),
    BREAKING_HAMMER("breaking_hammer", new BreakingHammer()),
    FIRST_SWORD("first_sword", new FirstSword()),

    FIRST_HELMET("first_helmet", new FirstArmor(ArmorItem.Type.HELMET)),
    FIRST_CHEST_PLATE("first_chest_plate", new FirstArmor(ArmorItem.Type.CHESTPLATE)),
    FIRST_LEGGINGS("first_leggings", new FirstArmor(ArmorItem.Type.LEGGINGS)),
    FIRST_BOOTS("first_boots", new FirstArmor(ArmorItem.Type.BOOTS)),

    SALT("salt", new Salt()),
    TIN("tin", new Tin()),
    BROKEN_TIN("broken_tin", new BrokenTin()),
    ANTHRACITE("anthracite", new Anthracite()),
    SILICON("silicon", new Silicon()),

    STONE_POT("stone_pot", new StonePot()),
    WATER_STONE_POT("water_stone_pot", new WaterStonePot()),
    LAVA_STONE_POT("lava_stone_pot", new LavaStonePot()),
    BRONZE("bronze", new Bronze()),
    BRONZE_LEAF("bronze_leaf", new BronzeLeaf()),
    REFRACTORY_BRICK("refractory_brick", new RefractoryBrick()),
    SHAPED_POWDER("shaped_powder", new ShapedPowder()),
    STEEL("steel", new Steel()),
    HOT_IRON("hot_iron", new HotIron()),
    HOT_IRON_1("hot_iron_1", new HotIron1()),
    HOT_IRON_2("hot_iron_2", new HotIron2()),
    STEEL_GEAR("steel_gear", new SteelGear()),
    STEEL_PLATE("steel_plate", new SteelPlate()),
    CRUSHING_TEETH("crushing_teeth", new CrushingTeeth()),
    SCREW("screw", new Screw()),
    NUT("nut", new Nut()),
    GEARBOX("gearbox", new Gearbox()),
    ;

    private final String name;
    private final Item item;

    ItemRegisterManager(String name, Item item) {
        this.name = name;
        this.item = item;
    }

    public static void onInitialize() {
        Arrays.stream(ItemRegisterManager.values()).forEach(
            itemEnum -> {
                Registry.register(
                    Registries.ITEM, new Identifier(StarryDimension.MOD_ID, itemEnum.getName()), itemEnum.getItem());
                ItemGroups.registerToGroup(itemEnum.getItem());
            }
        );
    }

    public String getName() {
        return name;
    }

    public Item getItem() {
        return item;
    }

}
